<?php
	session_start ();
	require_once ('funciones.php');
	if(isset($_REQUEST['btnModificarPassword']) && $_REQUEST['txtUsuario']!=null && $_REQUEST['txtPassword']!=null){
		$passwordModificada=$_REQUEST['txtNuevaPassword'];
		if($_REQUEST['txtPassword']==recuperarPasswordUsuario($_SESSION['id_usuario'])){
			actualizarPassword($_SESSION['id_usuario'], $passwordModificada);
		}
	}else{
	
?>
<!DOCTYPE html>
<html>
<head>
<title>Mantenimiento de Productos</title>
</head>
<body>
	<form name="cambioPassword" action="<?php htmlspecialchars($_SERVER['PHP_SELF']);?>" method="POST">
		<table>
			<tr>
				<td>Usuario: </td>
				<td><input type="text" name="txtUsuario" size="" maxlength=""></td>
				<?php 
					if(isset($_REQUEST['btnModificarPassword']) && $_REQUEST['txtUsuario']==null){
						echo "<font color='red'>Debe introducir el usuario </font>";
					}
				?>
			</tr>
			<tr>
				<td>Password: </td>
				<td><input type="password" name="txtPassword" size="" maxlength=""></td>
				<?php 
					if(isset($_REQUEST['btnModificarPassword']) && $_REQUEST['txtPassword']==null){
						echo "<font color='red'>Debe introducir la password </font>";
					}
				?>
			</tr>
			<tr>
				<td>Nueva Password: </td>
				<td><input type="password" name="txtNuevaPassword" size="" maxlength=""></td>
				<?php 
					if($_REQUEST['txtPassword']!=$_REQUEST['txtNuevaPassword']){
						echo "<font color='red'>Las password no coinciden </font>";
					}
				?>
			</tr>
			<tr>
				<td colspan="2"><input type="submit" name="btnModificarPassword" value="Modificar"></td>
			</tr>
		</table>
	</form>
</body>
</html>
<?php }?>
